package interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

public class CorsInterceptor implements Interceptor{

    @Override
    public void intercept(Invocation invocation) {
        invocation.getController().getResponse().addHeader("Access-Control-Allow-Origin", "*");
        invocation.getController().getResponse().addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
        invocation.getController().getResponse().addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
        invocation.invoke();//放行
    }
}
